
#ifndef __DSA_SIGNING_H
#define __DSA_SIGNING_H

#include "CryptoPipeBlock.h"
#include "../aprtools/APRBucketBrigade.h"
#include <openssl/dsa.h>
#include <openssl/evp.h>
#include "DSAPrivateKey.h"

/** Class encapsulating an interface to signing with an DSA private
 * key. */
class DSASigning : public CryptoPipeBlock
{
   public:
      DSASigning(const DSAPrivateKey &dsaprvkey);
      DSASigning(APRBucketBrigade &iinput, APRBucketBrigade &ioutput, const DSAPrivateKey &dsaprvkey);
      ~DSASigning();
      // Sign data block and return signed data block
      char *processDataBlock(const char *datablock, apr_size_t datasize, apr_size_t *signedsize);
      // Begin signing of the data pipe
      int processPipeBegin();
      // Step through the signing of the data pipe
      int processPipeStep();
      // Step through the data, recording data movement
      int processPipeStep(int *movementin, int *movementout);
      // End signing of the data pipe
      int processPipeEnd();
      /** Was the process secure? */
      int processWasSecure() { return 1; }
   private:
      /** A copy of the DSA private key. */
      DSA *key;
      /** The input bucket brigade. As this is pointer to the outside,
       * it is not deleted in the destructor. */
      APRBucketBrigade *input;
      /** The output bucket brigade. As this is pointer to the
       * outside, it is not deleted in the destructor. */
      APRBucketBrigade *output;
      /** The message digest context which holds the state of the
       * digest. */
      EVP_MD_CTX e_ctxt;
};

#endif
